import { ApiProperty } from '@nestjs/swagger'
import { IsString, IsOptional, MinLength, MaxLength, IsArray } from 'class-validator'
import { IsNumber } from 'class-validator'

/**
 * 创建角色DTO
 * 用于角色创建
 */
export class CreateRoleDto {
  @ApiProperty({ description: '角色名称', example: 'admin' })
  @IsString()
  @MinLength(2)
  @MaxLength(50)
  name: string

  @ApiProperty({ description: '角色显示名', example: '管理员' })
  @IsString()
  @MinLength(2)
  @MaxLength(50)
  label: string

  @ApiProperty({ description: '角色描述', example: '系统管理员', required: false })
  @IsOptional()
  @IsString()
  @MaxLength(200)
  description?: string

  @ApiProperty({ description: '角色排序', example: 0, required: false })
  @IsOptional()
  sort?: number

  @ApiProperty({ example: [1, 2], description: '权限ID列表' })
  @IsOptional()
  @IsArray()
  @IsNumber({}, { each: true })
  permissionIds?: number[]
}
